package com.example.myblogserver.common.context;

public class BaseContext {

    // 存储当前线程的UserEmail信息
    private static ThreadLocal<String> threadLocal = new ThreadLocal<>();

    public static void setCurrentUserEmail(String UserEmail) {
        threadLocal.set(UserEmail);
    }

    public static String getCurrentUserEmail() {
        return threadLocal.get();
    }

    public static void removeCurrentUserEmail() {
        threadLocal.remove();
    }

    public static void setCurrentUserId(Long userId) {
        threadLocal.set(userId.toString());
    }
    public static Long getCurrentUserId() {
        return Long.parseLong(threadLocal.get());
    }
    public static void removeCurrentUserId() {
        threadLocal.remove();
    }

}
